package com.catazy.mvvmlib.ext.lifecycle

import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import com.catazy.mvvmlib.callback.livedata.BooleanLiveData

/**
 * 作者: Tao
 * 日期: 2024/1/24
 * 时间: 17:56
 * 描述: AppLifecycleObserver
 * 主要作用: 用于监听应用是否在前台或者后台
 */
object AppLifecycleObserver : DefaultLifecycleObserver {

    //是否在前台
    var isForeground = BooleanLiveData()

    override fun onStart(owner: LifecycleOwner) {
        super.onStart(owner)
        isForeground.value = true
    }

    override fun onStop(owner: LifecycleOwner) {
        super.onStop(owner)
        isForeground.value = false
    }
}